package com.whimscrew.video.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

@Configuration
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {



    @Override
    public void configure(HttpSecurity http) throws Exception{
        //设置get请求的端点必须是ADMIN角色才能执行
        http.authorizeRequests()
            //匹配的Http端点和方法
          .antMatchers(HttpMethod.GET, "/*/video/**")
           //匹配的角色
          .hasRole("ADMIN")
          .anyRequest()
          .authenticated();
    }




}
